import React, { Component } from 'react'
import { Text, View, Button } from 'react-native'
import navigator from '../utils/navigator'

export default class GoBack extends Component {
  static navigationOptions = ({ navigation }) => {
    return {
      title: '我是GoBack，我来自' + navigation.state.params.from
    }
  }

  render () {
    let { goBack, dispatch, state } = this.props.navigation
    let { navigateTo, resetRouteTo, resetActiveRouteTo, backTo, setParams } = navigator
    console.log(this.props.navigation.state.routers)
    return (
      <View>
        <Button
          onPress={() => {goBack(null)}}
          title="goBack(null)">
        </Button>
        <Button
          onPress={() => {goBack(this.props.navigation.state.params.key)}}
          title="goBack(key)">
        </Button>
        <Button
          onPress={() => {
            dispatch(navigateTo('Home'))
          }}
          title="navigateTo">
        </Button>
        <Button
          onPress={() => {
            dispatch(setParams({from: 'other'}, state.key))
          }}
          title="setParams">
        </Button>
      </View>
    )
  }
}

